import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
  Search = '/risk/search',
  companyList = '/company-monitor/company',
  CancelMonitoring = '/company-monitor/company/remove',
  RiskRecord = '/company-monitor/risk-record',
  RiskReport = '/company-monitor/risk-report',
  MonitorConfig = '/company-monitor/config',
  SaveConfig = '/company-monitor/config',
  SaveCompany = '/company-monitor/company',
  GetCompanyInfo = '/company',
  GetCompanyMonitorDetail = '/company-monitor/risk/detail',
  GetOptions = '/company-monitor/push/rulesSelect',
}

// 获取监控企业列表（分页）
export function getCompanyList(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.companyList, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取监控动态列表（分页）
export function getRiskRecord(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.RiskRecord, params },
    {
      errorMessageMode: mode,
    },
  );
}

//取消监控
export function removeCompany(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.CancelMonitoring, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 保存监控配置
export function saveCompany(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.SaveCompany, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取监控报告
export function getRiskReport(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.RiskReport, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取监控配置
export function getConfig(mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.MonitorConfig },
    {
      errorMessageMode: mode,
    },
  );
}

// 保存监控配置
export function saveConfig(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.SaveConfig, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取公司详情
export function getCompanyInfo(id: string, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetCompanyInfo + `/${id}` },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取监控信息详情
export function getCompanyMonitorDetail(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.GetCompanyMonitorDetail, data: data },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取筛选下拉
export function getOptions(mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetOptions },
    {
      errorMessageMode: mode,
    },
  );
}
